package com.itheima.four;

import java.net.ServerSocket;
import java.net.Socket;

//利用线程池技术进行伪异步I/O
public class Server {
    public static void main(String[] args) {
        try{
            //1.注册端口
            ServerSocket ss=new ServerSocket(9999);
            //2.定义一个循环接受Socket对象
            //实例化线程池
            HandlerSocketServerPool pools=new HandlerSocketServerPool(3,10);
            while(true){
                Socket socket=ss.accept();
                //3.把Socket对象交给线程池处理
                //4.将Socket封装为一个任务对象
                Runnable target=new ServerRunnableTarget(socket);
                pools.execute(target);
            }
        }catch (Exception e){
            System.out.println("有人下线了");
        }
    }
}
